package com.bdzl.auth.test;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/loan/Auth/test")
@RefreshScope//实现配置自动更新
public class LoanAuthTestController {
    @Value("${config.info}")
    private String configInfo;
    @Value("${spring.application.name}")
    private String appName;

    /**
     * 获取 loanAuth的配置文件信息
     *
     * @return
     */
    @GetMapping("/config/info")
    public String getConfigInfo() {
        return "微服务名称：" + appName + "，微服务描述：" + configInfo;
    }

    /**
     * 微服务熔断降级测试
     *
     * @return
     */
    @GetMapping(value = "/feigntimeout")
    public String feigntimeout() {
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "微服务熔断测试feigntimeout，微服务名称：" + appName + "，微服务描述：" + configInfo;
    }
}


